clear all;
close all;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
gr1= imread('1gr.jpg');
gr2= imread('2gr.jpg');
gr5= imread('5gr.jpg');
gr10= imread('10gr.jpg');
gr20= imread('20gr.jpg');
gr50= imread('50gr.jpg');
zl1= imread('1zl.jpg');
zl2= imread('2zl.jpg');
zl5= imread('5zl.jpg');



imgCell = {gr1,gr2,gr5,gr10,gr20,gr50,zl1,zl2,zl5};
%imgCell{1}
%fgray = rgb2gray(imgCell{1});

fileID = fopen('coin_pattern.txt','w');
for x=1:9
    f = imgCell{x};
    fgray = rgb2gray(f);
    
    %bw1 = im2bw(f,160/255);
    %bw2 = ~im2bw(f,220/255);
    %bw = immultiply(bw1,bw2);
    
    canny = edge(fgray, 'canny');
    fbin = canny;
    
    se = strel('disk',4);
    img = imclose(fbin,se);
    %figure
    %imshow(img);
    
    img2 = imresize(img,0.20);
    figure
    imshow(img2);
    
    d2 = im2double(img2);
    d2bis = d2';
    d1 = d2bis(:)';
    
    fprintf(fileID,'%d ',d1);
    fprintf(fileID,'\n');
    
end

fclose(fileID);
type coin_pattern.txt

% fgray = rgb2gray(f);
% 
% bw1 = im2bw(f,160/255);
% bw2 = ~im2bw(f,220/255);
% bw = immultiply(bw1,bw2);
% 
% canny = edge(fgray, 'canny');
% fbin = canny;
% 
% se = strel('disk',4);
% img = imclose(fbin,se);
% %imshow(img1);
% 
% img2 = imresize(img,0.1);
% %figure
% %imshow(img2);
% d2 = im2double(img2);
% 
% d2bis = d2';
% d1 = d2bis(:)'
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% fileID = fopen('coin_pattern.txt','w');
% 
% fprintf(fileID,'%d ',d1);
% fprintf(fileID,'\n');
% 
% fclose(fileID);
% 
% type coin_pattern.txt



